package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle string  `gorm:"type:varchar(100);index;not null;comment:商品名称"`
	GoodsPrice float32 `gorm:"type:decimal(10,2);not null;comment:商品价格"`
	GoodsStock int64   `gorm:"type:int;not null;default 0;comment:商品库存"`
	GoodsCover string  `gorm:"type:varchar(255);comment:商品封面"`
}

func (g *Goods) Create() error {
	return DB.Create(&g).Error
}
func (g *Goods) Detail(goodsId int) error {
	return DB.Where("id =?", goodsId).First(&g).Error
}
